crane package options modified exposing WithPageSize #2062
+21
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Crane package options modified exposing WithPageSize, adding pageSize option, and including a test for the function.
When using pkg/crane to retrieve the catalog of a registry, the pageSize of the GET request to a registry, n, is not exposed to the options structure or function. Although the default value of 1000 is intended to be used, the registry manifest default of 10000 is used instead. This causes an error when using the official registry:
docker run -d -p 5000:5000 --restart always --name registry registry:2
repos, err = crane.Catalog(reg, options...)
Error:
"errors":[{"code":"PAGINATION_NUMBER_INVALID","message":"invalid number of results requested","detail":{"n":10000}}],"StatusCode":400}
This is the same error as using curl:
curl http://localhost:5000/v2/_catalog?n=10000 {"errors":[{"code":"PAGINATION_NUMBER_INVALID","message":"invalid number of results requested","detail":{"n":10000}}]}
It is not possible to pass the page size n value to the crane package as the function and option is not exposed outside of the lower level pkg/remote options. The effect is that as a value is not being set, the unintended default of 10000 is used, which the official registry image is not happy about.
There may be a more elegant or architecturally sound fix but my changes below fix the issue.